package com.vcg.example.service;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.vcg.example.model.User;

/**
 * 
 * @author wuyu
 *
 */
@RequestMapping("/user")
public interface UserService {

	// 可以不指定produce 默认会自动序列化成json
	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
	public User findById(@PathVariable("id") Integer id);

	// 只接受请求头为application/json
	@RequestMapping(value = "/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
	// 只做简单返回
	public User insert(@RequestBody User user);

	// 注入request,response
	@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
	public Integer delete(@PathVariable("id") Integer id);

	// 注入request,response
	@RequestMapping(value = "/", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
	public User update(@RequestBody User user);


}